using Boo.Lang;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[Serializable]
public class AIforcearcade : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	internal sealed class _0024delay_0024240 : GenericGenerator<WaitForSeconds>
	{
		internal AIforcearcade _0024self__0024242;

		public _0024delay_0024240(AIforcearcade self_)
		{
			_0024self__0024242 = self_;
		}

		public override IEnumerator<WaitForSeconds> GetEnumerator()
		{
			return new _0024(_0024self__0024242);
		}
	}

	public Rigidbody rigi;

	public Transform target;

	public Transform tr;

	public int state;

	public Rigidbody tgrigi;

	public int direction;

	public AIforcearcade()
	{
		direction = 1;
	}

	public void Start()
	{
		if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.Contains("MP"))
		{
			target = GameObject.Find("PlayerPrefab(Clone)").transform;
		}
		else
		{
			target = GameObject.Find("knight dranzer").transform;
		}
		tgrigi = (Rigidbody)target.GetComponent(typeof(Rigidbody));
		StartCoroutine(delay());
	}

	public void check()
	{
		if (!(tgrigi.angularVelocity.sqrMagnitude >= 10f))
		{
			gameObject.SetActive(false);
		}
		if (!(rigi.angularVelocity.sqrMagnitude >= 10f))
		{
			PlayerPrefs.SetInt("Stopped", PlayerPrefs.GetInt("Stopped") + 1);
			CancelInvoke("random");
			CancelInvoke("attack");
			CancelInvoke("evade");
			gameObject.SetActive(false);
			CancelInvoke("check");
		}
	}

	public void FixedUpdate()
	{
		tr.LookAt(target.position);
		rigi.AddForce(tr.TransformDirection(new Vector3(0f, 0f, 1f)) * 11f);
	}

	public IEnumerator delay()
	{
		return new _0024delay_0024240(this).GetEnumerator();
	}

	public void evade()
	{
		rigi.AddForce(tr.TransformDirection(new Vector3(0f, 0f, -1f)) * 50f);
	}

	public void random()
	{
		rigi.AddForce(new Vector3(UnityEngine.Random.Range(-3, 3), 0f, UnityEngine.Random.Range(-3, 3)) * UnityEngine.Random.Range(40, 60));
	}

	public void attack()
	{
		rigi.AddForce(tr.TransformDirection(new Vector3(0f, 0f, 1f)) * UnityEngine.Random.Range(40, 60));
	}

	public void Main()
	{
		InvokeRepeating("check", 1f, 0.7f);
		InvokeRepeating("random", 1f, UnityEngine.Random.Range(1.5f, 3f));
		InvokeRepeating("attack", 1f, UnityEngine.Random.Range(1.5f, 3f));
		InvokeRepeating("evade", 1f, UnityEngine.Random.Range(2, 4));
	}
}
